#ifndef EMFGRID_H
#define EMFGRID_H
#include "polygondata/polygondata.h"
#include "color/colorscale.h"
#include "drawables/emfcolorscaledrawable.h"

class EmfGrid
{
private:
    QSharedPointer<PolygonData> _polygonData;

    enum MeshParams
    {
        MESH_SIZE = 200,
        MESH_PRECISION = 1
    };
    QColor _meshColors[MESH_SIZE][MESH_SIZE];
    double _meshValues[MESH_SIZE][MESH_SIZE];
    QRectF _boundingBox;

    EmfColorScaleDrawable *_colorScaleDrawable;

    double _dx;
    double _dy;
private:
    void _getBoundingBox();
    double _pow2(double number);
    double _getDistance(QPointF p1, QPointF p2);
    double _getValueByPoint(QPointF point);
    bool _isPointsTooFar(QPointF p1, QPointF p2);

public:
    EmfGrid();
    void recalculateColors(QProgressDialog *progressHandler);
    void setPolygonData(QSharedPointer<PolygonData> polygonData);
    void draw(QGLWidget *textRenderer);
};

#endif // EMFGRID_H
